Skip to content

feat(core,cli): M5.2 — plugin live wire-up (discover → spawn → register)#20

Merged
oratis merged 1 commit into
mainfrom
feat/m5.2-plugin-wireup
May 28, 2026
Merged

feat(core,cli): M5.2 — plugin live wire-up (discover → spawn → register)#20
oratis merged 1 commit into
mainfrom
feat/m5.2-plugin-wireup

Conversation

@oratis

@oratis oratis commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the M5.1: 65% — needs live registry wireup gap. Plugins are now first-class: they discover, spawn, contribute hook handlers, and are visible via /plugins.

Core

  • packages/core/src/plugins/wireup.ts (NEW) — wirePlugins() orchestrates discover → spawn → merge contributed hooks. Returns plugins, hash mismatches, spawn failures, and a shutdown() so the host doesn't leak child processes.
  • HookDispatcher.mergeHooks(extra) — runtime extension of matchers per event. Plugins use this to inject command/http/prompt hooks.
  • PluginSubprocess.plugin / isAlive accessors — wire-up can match running subprocesses back to their source manifest without poking private state.
  • agent.tsToolContext.sessionDir is now ${sessions.root}/${sessionId}, so TodoWrite persists per-session and /todos can read it.

CLI

  • /plugins — lists active plugins with their version + contributed hook events + drift/failure warnings.
  • /todos rewritten — actually reads <sessionDir>/todos.json.
  • REPL and headless both wire/shutdown plugins at start/end. Capability bridge routes plugin fs/bash/fetch calls through the host's tool implementations (so they're subject to the same permissions stack as the agent).

Test plan

  • pnpm -r test317 + 47 = 364 passing (was 308 + 43 = 351; +13 across wireup + commands)
  • pnpm -F @deepcode/core build + pnpm -F deepcode-cli build — clean
  • BEHAVIOR_PARITY.md/todos and /plugins move from 🔄 to ✅

What's NOT in this PR (tracked separately)

  • OS-level sandbox wrapping of the plugin subprocess (M5.1-ext)
  • gh:user/repo and npm install paths (M5.2-rest)
  • Marketplace index.json + ed25519 signatures + revoked.json (M5.2-rest)

🤖 Generated with Claude Code

Closes the "M5.1: 65% — needs live registry wireup" line item.

Core (@deepcode/core):
  · packages/core/src/plugins/wireup.ts (NEW, ~140 lines)
    - wirePlugins({ home, hooks, capabilities, disabled }) — orchestrates
      discoverPlugins → spawnAllPlugins → mergeHooks(declared) for each
      successfully started plugin.
    - WireResult exposes plugins (with contributed hook events), hash
      mismatches, spawn failures, and a shutdown() to kill subprocesses.
    - hasInstalledPlugins() probe helper.
  · packages/core/src/hooks/dispatcher.ts
    - HookDispatcher.mergeHooks(extra: Hooks) — appends matchers under each
      event so plugins can extend dispatch at runtime.
    - `hooks` field changed from readonly to private mutable.
  · packages/core/src/plugins/runtime/subprocess.ts
    - Exposes `get plugin()` and `get isAlive()` accessors so wireup can map
      subprocess back to its source InstalledPlugin without reaching into
      private opts.
  · packages/core/src/agent.ts
    - ToolContext.sessionDir is now derived from
      `${sessions.root}/${sessionId}` so TodoWrite persists to the
      session-scoped dir and /todos can read it back.

CLI (deepcode-cli):
  · apps/cli/src/repl.ts + headless.ts
    - Both bootstraps now call wirePlugins() after HookDispatcher
      construction, build a capability bridge from BashTool/ReadTool/WriteTool/
      WebFetchTool, and shutdown() the wire on exit.
    - SessionContext carries wiredPlugins + pluginWarnings so /plugins can
      render them.
  · apps/cli/src/commands.ts
    - NEW /plugins slash command. Lists active plugins with their version
      and contributed hook events; surfaces hash drift + spawn failure
      warnings.
    - /todos rewritten — now actually reads
      `<sessionsRoot>/<sessionId>/todos.json` via readTodos() helper.

Tests: core 308 → 317 (+9 wireup tests); cli 43 → 47 (+4 /plugins+/todos);
total 360 → 364 passing. (`pnpm -r test`).

BEHAVIOR_PARITY: /todos and /plugins move from 🔄 to ✅.

Acknowledged gaps (M5.2-ext+):
  · OS-level sandbox wrapping of plugin subprocess (M5.1-ext)
  · gh:user/repo + npm install paths (M5.2-rest)
  · Marketplace index + ed25519 signatures (M5.2-rest)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@oratis oratis merged commit d62cd7a into main May 28, 2026
1 of 2 checks passed
@oratis oratis deleted the feat/m5.2-plugin-wireup branch May 28, 2026 05:30
oratis added a commit that referenced this pull request May 28, 2026
This session ("继续推进" from v2) added 5 PRs on top of #1-#16:
  · #17 M3c-rest tools (TodoWrite + WebFetch + WebSearch)
  · #18 M3.5 attack tests + security-model.md
  · #19 M8 headless mode (-p / --print)
  · #20 M5.2 plugin live wire-up
  · #21 system-reminder injector

Test count: 313 → 387 (+74).
Scope completion estimate: 65-70% → 72-78%.

Major remaining items: M6 Mac Electron (still 0%), M7 file panel (depends
on M6), and the M3c-rest/M8/M5.2 leftovers itemized in the body.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant